#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

int gval = 0;
int main()
{

  printf("hello, my pid: %d, my ppid = %d\n", getpid(), getppid());
  pid_t id = fork();
  if (id > 0)
  {
  
      while(1)
      {
           printf("i am a Dad, pid: %d, ppid: %d, ret id: %d, gval: %d\n", getpid(), getppid(), id, gval);
           sleep(1);
      }
  }
  else if (id == 0)
  {
      while(1)
      {
        printf("i am a Son, pid: %d, ppid: %d, ret id: %d, gavl: %d\n", getpid(), getppid(), id, gval);
        gval++;
        sleep(1);
      }
  }

  // pid_t id = fork();
  //(void)id;
  //printf("i am a fork, my pid: %d, my ppid: %d\n", getpid(), getppid());

  //FILE *fp = fopen("log.txt","w");
  //if (fp == NULL){

  //}
  //pid_t ppid = getppid();
  //pid_t id  = getpid();
  //while(1)
  //{
  //  printf("hello bit, my pid: %d, my ppid = %d\n", id, ppid);
  //  sleep(1);
  //}

}
